import { zlRequest } from "../index";

interface QueryType {
  pageNum: number;
  pageSize: number;
}

export const queryArticle = (data: any, query: QueryType) => {
  return zlRequest.post({
    url: `/keyword/search/list?pageNum=${query.pageNum}&pageSize=${query.pageSize}`,
    showLoading: true,
    data
  });
};


// 获取文章详情
interface QueryInfoType {
  id: string
  searchType: string
}

export const queryArticleInfo = (data: QueryInfoType) => {
  return zlRequest.get({
    url: `/keyword/search/detail/${data.id}?searchType=${data.searchType}&name=${data.name}`,
    showLoading: false,
  });
}

// 点赞收藏
interface FavoriteType {
  sourceId: string,
  sourceType: "1" | "2" | "3" | "4",
  type: "1" | "2"
}
export const handleArticleStatus = (data: FavoriteType) => {
  return zlRequest.post({
    url: `/article/article/favorites?sourceId=${data.sourceId}&sourceType=${data.sourceType}&type=${data.type}`,
    showLoading: false,
  })
}

// 获取政策关联项目
export function getProjectRes(query: any) {
  return zlRequest.get({ url: `/item/item/getItemDataList?pageNum=${query.pageNum}&pageSize=${query.pageSize}&policyId=${query.id}`, showLoading: false },);
}

// 获取热门信息
export function hotInformation(id: number) {
  return zlRequest.get({ url: `/article/article/getHotInformation?type=`+id, showLoading: false },);
}

// 获取资讯汇总
export function getNewsCollect(query: any,data: any) {
  return zlRequest.post({ url: `/article/article/getInformationCollect?pageNum=${query.pageNum}&pageSize=${query.pageSize}`, data, showLoading: false })
}

/**
 * 数据分析接口
 */

// 金额饼
export function getPricePieData(params: any) {
  return zlRequest.get({ url: `/item/item/getItemStatisticsByAmount`, params, showLoading: false })
}

// 地区饼
export function getAreaPieData(params: any) {
  return zlRequest.get({ url: `/item/item/getItemStatisticsByArea`, params, showLoading: false })
}

// 性质饼
export function getNaturePieData(params: any) {
  return zlRequest.get({ url: `/item/item/getItemStatisticsByNature`, params, showLoading: false })
}

// 行业饼
export function getIndustryPieData(params: any) {
  return zlRequest.get({ url: `/item/item/getItemStatisticsByIndustry`, params, showLoading: false })
}

// 等级饼
export function getCompanyItemStatisticsByLevel(id: any) {
  return zlRequest.get({ url: `/item/item/getCompanyItemStatisticsByLevel?companyId=${id}`, showLoading: false })
}
// 部门饼
export function getCompanyItemStatisticsByOrg(id: any) {
  return zlRequest.get({ url: `/item/item/getCompanyItemStatisticsByOrg?companyId=${id}`, showLoading: false })
}
// 批次饼
export function getCompanyItemStatisticsByYear(id: any) {
  return zlRequest.get({ url: `/item/item/getCompanyItemStatisticsByYear?companyId=${id}`, showLoading: false })
}
// 金额饼
export function getCompanyItemStatisticsByAmount(id: any) {
  return zlRequest.get({ url: `/item/item/getCompanyItemStatisticsByAmount?companyId=${id}`, showLoading: false })
}

/**
 * 数据图谱接口
 */
type ApiNameType = "getParentPolicy" | "findPolicyRel" | "findPolicyManageRel" | "findPolicyEvolutionRel" | "getParentOrgTree" | "findOrgPolicy"
type PathType = "/org/org" | "/article/article_policy"
export function getAtlasData(params: any, apiName: ApiNameType, path: PathType) {
  return zlRequest.get({ url: `${path}/${apiName}`, params, showLoading: false })
}


/**
 * 专利数据接口
 *
 * /company/company/listCompanyPatent 专利信息
/company/company/listCompanyAccs  软件著作权
参数:companyId 企业id
 */
export function getCompanyPatent(params: { companyId: string }) {
  return zlRequest.get({ url: "/company/company/listCompanyPatent", showLoading: false, params })
}

/**
 * 软件著作权接口
 */
export function getCompanyAccs(params: { companyId: string }) {
  return zlRequest.get({ url: "/company/company/listCompanyAccs", showLoading: false, params })
}

/**
 * 获取提示语
 */
export function getCompanyTips(id: string) {
  return zlRequest.get({ url: `/item/item/getCompanyItemStatistics?companyId=${id}`, showLoading: false });
}

